<?php
namespace app\onlineRepair\controller;
use app\common\Base;
use think\Db;

class RepairTypeConf extends Base {
	
	public function index() {
		return $this->fetch();
	}

	public function pageQuery() {
		$result = Db::table("报修类别")->select();
		return selectResult($result);
	}

	public function addUpdate() {
		try {
			$param = request()->param();
			if(array_key_exists("ID", $param)) {
				update('报修类别', $param);
			}else {
				insert('报修类别', $param);
			}
			return '000';
		} catch (Exception $e) {
			echo $e->getMessage();
		}
		return "999";
	} 

	public function del() {
		$delIds = input("delIds");
		try {
			Db::name('报修类别')->where('ID','in',explode(",", $delIds))->delete();
			return "000";
		} catch (Exception $e) {
			echo $e->getMessage();
		}
		return "999";
	}

	public function list() {
		$result = Db::table("报修类别")
				  ->field("类别名称 value")
				  ->select();
		$list = [];
		foreach ($result as $key => $obj) {
			$list[$key] = array("text"=>$obj["value"], "value"=>$obj["value"]);
		}
		return $list;
	}

}
